package cn.yunhe.services.impl;

import cn.yunhe.dao.UserMapper;
import cn.yunhe.entity.User;
import cn.yunhe.services.IUserService;
import cn.yunhe.utils.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class UserService implements IUserService {
    SqlSession session = SqlSessionFactoryUtil.getSession();
    UserMapper userMapper = session.getMapper(UserMapper.class);

    @Override
    public User login(String uname, String upwd) {
        User user = new User(uname, upwd);
        User u1 = userMapper.login(user);
        return u1;
    }

    @Override
    public List<User> userList() {
        return userMapper.userList();
    }

    @Override
    public int addUser(User user) {
        int row=userMapper.addUser(user);
        session.commit();
        return row;
    }

    @Override
    public int delUser(User user) {
        int row=userMapper.delUser(user);
        session.commit();
        return row;
    }
}
